import 'package:car_map/mode/count_model.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

class WidgetLicenseTime extends StatelessWidget {

  final CountModel countModel;

  const WidgetLicenseTime({Key key, this.countModel}) : super(key: key);


  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return Column(
      children: <Widget>[
        listHorizontal(null,-1),
       ListView.builder(itemBuilder: (context,index){
         return listHorizontal(countModel.data[index],index);
       },itemCount: countModel.data.length ,shrinkWrap: true,)
      ],
    );
  }

  Widget listHorizontal(CarCountInfoEntityData carCountInfoEntityData,int currendIndex) {
    return Row(
      children: <Widget>[
        listItem(currendIndex==-1?'车牌号码':carCountInfoEntityData.license),
        Container(
          color: carCountInfoEntityData==null?Colors.blue:Colors.white,
          height: ScreenUtil().setHeight(70.0),
          width: ScreenUtil().setWidth(600),
          child: ListView.builder(
            itemBuilder: (BuildContext context, int index) {
              return listItem(carCountInfoEntityData==null?countModel.timeDate[index].timeDate:carCountInfoEntityData.data[currendIndex].consumptionValue);
            },
            itemCount: 10,
            scrollDirection: Axis.horizontal,
            shrinkWrap: true,
          ),
        )
      ],
    );
  }

  Widget listItem(dynamic value) {
    return Container(
      height: ScreenUtil().setHeight(70.0),
      width: ScreenUtil().setWidth(150.0),
      alignment: Alignment.center,
      decoration:
          BoxDecoration(border: Border.all(color: Colors.black12, width: 0.5)),
      padding: EdgeInsets.only(left: 10.0, right: 10.0, top: 5.0, bottom: 5.0),
      child: Text('${value}',style: TextStyle(fontSize: ScreenUtil().setSp(23.0)),),
    );
  }
}
